<?php

namespace services\models\minisite;

use Yii;
use yii\data\ActiveDataProvider;

/**
 * This is the model class for table "d_mini.t_activity_show_feel_reply".
 *
 * @property integer $id
 * @property integer $as_id
 * @property integer $asf_id
 * @property string $c_content
 * @property integer $uid
 * @property string $db_time
 */
class MActivityShowFeelReply extends \common\models\minisite\MActivityShowFeelReply
{
    public function getMactivityShowFeel()
    {
        return $this->hasOne(MActivityShowFeel::className(), ['id'=>'as_id']);
    }

    public function getList($asf_id)
    {
        $query = MActivityShowFeelReply::find();


        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'pagination' => [
                'pageSize' => 10,
            ],
            'sort'=>[
                'defaultOrder'=>[
                    'id'=>SORT_DESC
                ]
            ],
        ]);

        $query->andFilterWhere([
            'asf_id' => $asf_id,
        ]);

        return $dataProvider;
    }

    /**
     * @param bool $insert
     * @return bool
     */
    public function beforeSave($insert)
    {

        if(!empty($this->c_content)){
            /**
             * 过滤敏感字
             */
            $filter = new \services\models\ProhibitedWords();
            $this->c_content = $filter->filterWords($this->c_content);
        }
        return parent::beforeSave($insert);
    }
}
